package com.jpyl.jpMedicalTreatment.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jpyl.jpMedicalTreatment.R;
import com.jpyl.jpMedicalTreatment.model.PopwindowModel;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 底部弹框适配器
 * Created by 15697 on 2019/3/8.
 */

public class PopupWindowAdapter extends BaseAdapter {
    List<PopwindowModel> list;
    Context context;

    public PopupWindowAdapter(Context context,List<PopwindowModel> list ) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.activity_item_popwindow, null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.tvItemPopwindowName.setText(list.get(i).getName());

        return view;
    }


    static class ViewHolder {
        @BindView(R.id.tv_itemPopwindow_name)
        TextView tvItemPopwindowName;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }



}
